﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Table.aspx.cs" Inherits="Manage_Database_Table" %>
<html>
<head>
<!--#include file="../js/html_head.inc"-->
<link rel="stylesheet" type="text/css" href="../Themes/<%=ManageHelper.GetTheme()%>/style.css" />
</head>
<body>
<%=ManageHelper.PageSucMsg()!=""?"<div class='msg_succeed'>"+ManageHelper.PageSucMsg()+"</div>":""%>
<%=ManageHelper.PageErrMsg()!=""?"<div class='msg_failed'>"+ManageHelper.PageErrMsg()+"</div>":""%>

<script language="JavaScript" type="text/javascript">
<!--
	function changestyle(id){
		document.getElementById("maindiv").className="class_"+id;
	}
	function showtable(id){
	    document.getElementById("tab_"+id).style.display="block";
	    document.getElementById("a_show_"+id).style.display="none";
	    document.getElementById("a_hide_"+id).style.display="block";
	}
	function hidetable(id){
	    document.getElementById("tab_"+id).style.display="none";
	    document.getElementById("a_show_"+id).style.display="block";
	    document.getElementById("a_hide_"+id).style.display="none";
	}
	function showall()
	{
	    <%
	    if(act=="")
	    {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if(ds.Tables[0].Rows[i]["表名"].ToString()!=""){
            %>  document.getElementById("tab_<%=ds.Tables[0].Rows[i]["表名"].ToString()%>").style.display="block";
                document.getElementById("a_show_<%=ds.Tables[0].Rows[i]["表名"].ToString()%>").style.display="none";
	            document.getElementById("a_hide_<%=ds.Tables[0].Rows[i]["表名"].ToString()%>").style.display="block";
            <%
                }
            }
        }
        %>
	    document.getElementById("a_show_all").style.display="none";
	    document.getElementById("a_hide_all").style.display="block";
	}
	function hideall()
	{
	    <%
	    if(act=="")
	    {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if(ds.Tables[0].Rows[i]["表名"].ToString()!=""){
            %>  document.getElementById("tab_<%=ds.Tables[0].Rows[i]["表名"].ToString()%>").style.display="none";
                document.getElementById("a_show_<%=ds.Tables[0].Rows[i]["表名"].ToString()%>").style.display="block";
	            document.getElementById("a_hide_<%=ds.Tables[0].Rows[i]["表名"].ToString()%>").style.display="none";
            <%
                }
            }
        }
        %>
        document.getElementById("a_show_all").style.display="block";
	    document.getElementById("a_hide_all").style.display="none";
	}
//-->
</script>


<div class="column">
    <div class="columntitle">操作区</div>
    <table cellspacing="0" cellpadding="0" rules="all" align="center" border="0" id="MyDataGrid" style="border-width:0px;width:100%;border-collapse:collapse;">
        <tr class="tdbg" onmouseover="this.className='tdbg-dark';" onmouseout="this.className='tdbg';" style="height:25px; ">
            <td style="width:10px">&nbsp;</td>
		    <td><a id="a_show_all" style="display:none; text-decoration:none;" href="###" onclick="showall()" title="全部展开">+全部展开</a></td>
            <td><a id="a_hide_all" style="text-decoration:none;" href="###" onclick="hideall()" title="全部收起">-全部收起</a></td>
            <% if (act == "db"){%><td align="left"><a href="table.aspx"><span style="color:Maroon"><<返回</span></a></td><%} %>
	    </tr>
    </table>
</div>

<% 
if (act == "db")
{
%>
<div class="column">
    <div class="columntitle"><%=tbl%></div>
        <table cellspacing="0" cellpadding="0" rules="all" Align="center" border="0" style="border-width:0px;width:100%;border-collapse:collapse;">
	    <thead>
	    <tr class="summary-title" style="height: 25px" align="left">
		    <%
            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
            %>
		    <td><%=ds.Tables[0].Columns[i].ToString()%></td>
		    <%} %>
	    </tr>
	    </thead>
	    <tbody>
	    <%
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
        %>
        <tr class="tdbg" onmouseover="this.className='tdbg-dark';" onmouseout="this.className='tdbg';" style="height:25px;" align="left">
        <%
            for (int ii = 0; ii < ds.Tables[0].Columns.Count; ii++)
            {
            %>
		    <td><%=ds.Tables[0].Rows[i][ii].ToString() == "" ? "&nbsp;" : ds.Tables[0].Rows[i][ii].ToString()%></td>
		    <%} %>
		</tr>
        <%} %>
	    </tbody>
	</table>
</div>
<%
}
else
{
%>

    <%
    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
    {
        if (ds.Tables[0].Rows[i]["表名"].ToString() != "")
        {
    %>
    <div class="column">
    <div class="columntitle">
        <table id="tit_<%=ds.Tables[0].Rows[i]["表名"].ToString()%>" border="0" cellspacing="0" cellpadding="0" >
	        <tr style="height: 25px">
		        <td>&nbsp;<B><%=ds.Tables[0].Rows[i]["表名"].ToString()%></B>&nbsp;</td>
		        <td>&nbsp;<span style="color:Maroon"><%=ds.Tables[0].Rows[i]["表说明"].ToString()%></span>&nbsp;</td>
		        <td><a id="a_show_<%=ds.Tables[0].Rows[i]["表名"].ToString()%>" style="display:none; text-decoration:none;" href="###" onclick="showtable('<%=ds.Tables[0].Rows[i]["表名"].ToString()%>')" title="展开">+展开</a></td>
                <td><a id="a_hide_<%=ds.Tables[0].Rows[i]["表名"].ToString()%>" style="text-decoration:none;" href="###" onclick="hidetable('<%=ds.Tables[0].Rows[i]["表名"].ToString()%>')" title="收起">-收起</a></td>
                <td>&nbsp;<a href="?act=db&tbl=<%=ds.Tables[0].Rows[i]["表名"].ToString()%>">数据</a></td>
	        </tr>
        </table>
    </div>
    <table id="tab_<%=ds.Tables[0].Rows[i]["表名"].ToString()%>" cellspacing="0" cellpadding="0" rules="all" align="center" border="0" style="border-width:0px;width:100%;border-collapse:collapse;">
	    <thead>
	    <tr class="summary-title" style="height: 25px" align="left">
		    <td align="center">序号</td>
		    <td>字段名</td>
		    <td>标识</td>
		    <td>主键</td>
		    <td>类型</td>
		    <td>字节数</td>
		    <td>长度</td>
		    <td>小数位数</td>
		    <td>允许空</td>
		    <td>默认值</td>
		    <td>字段说明</td>
	    </tr>
	    </thead>
	    <tbody>
        <%}%>
	    <tr class="tdbg" onmouseover="this.className='tdbg-dark';" onmouseout="this.className='tdbg';" style="height:25px;" align="left">
		    <td align="center"><%=ds.Tables[0].Rows[i]["字段序号"].ToString()%></td>
		    <td><%=ds.Tables[0].Rows[i]["字段名"].ToString()%></td>
		    <td><%=ds.Tables[0].Rows[i]["标识"].ToString() == "" ? "&nbsp;" : ds.Tables[0].Rows[i]["标识"].ToString()%></td>
		    <td><%=ds.Tables[0].Rows[i]["主键"].ToString() == "" ? "&nbsp;" : ds.Tables[0].Rows[i]["主键"].ToString()%></td>
		    <td><%=ds.Tables[0].Rows[i]["类型"].ToString()%></td>
		    <td><%=ds.Tables[0].Rows[i]["占用字节数"].ToString()%></td>
		    <td><%=ds.Tables[0].Rows[i]["长度"].ToString()%></td>
		    <td><%=ds.Tables[0].Rows[i]["小数位数"].ToString()%></td>
		    <td><%=ds.Tables[0].Rows[i]["允许空"].ToString() == "" ? "&nbsp;" : ds.Tables[0].Rows[i]["允许空"].ToString()%></td>
		    <td><%=ds.Tables[0].Rows[i]["默认值"].ToString() == "" ? "&nbsp;" : ds.Tables[0].Rows[i]["默认值"].ToString()%></td>
		    <td><%=ds.Tables[0].Rows[i]["字段说明"].ToString() == "" ? "&nbsp;" : ds.Tables[0].Rows[i]["字段说明"].ToString()%></td>
	    </tr>
        <%
        if (i < ds.Tables[0].Rows.Count - 1)
        {
            if (ds.Tables[0].Rows[i + 1]["表名"].ToString() != "")
            {
                Response.Write("</tbody></table></div>");
            }
        }
        else
        {
            Response.Write("</tbody></table></div>");
        }
    }
    %>
    
<%    
}
%>







</body>
</html>